let Room = require('../../moudles/accessdb/dao/roomQueryAll')

/**
 * 查看所有的房型 这里调用数据库
 * @returns {Promise<unknown>}
 */
async function handleRequest() {
    return new Promise(async (resolve, reject) => {
        Room.findAll().then((res) => {
            resolve(res)
        }).catch((e) => {
            reject(e);
        })
    });
}


async function handleRequestByCategoty(value) {
    return new Promise(async (resolve, reject) => {
        Room.findAll(
            {
                where: {categoryId: value.categoryId}
            }
        ).then((res) => {
            resolve(res)
        }).catch((e) => {
            reject(e);
        })
    });
}

async function handleRequestByQueryRoom(value) {
    return new Promise(async (resolve, reject) => {
        Room.findOne(
            {
                where: {roomId: value.roomId}
            }
        ).then((res) => {
            resolve(res)
        }).catch((e) => {
            reject(e);
        })
    });
}

module.exports = {handleRequest, handleRequestByCategoty,handleRequestByQueryRoom};